home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 48
/
Amiga Format CD48 (1999-12-13)(Future Publishing)(GB)(Track 1 of 2)[!][issue 2000-01].iso
/
-in_the_mag-
/
workbench
/
html
/
1st_linkchecker
/
extlinkchecker
< prev
next >
Wrap
Text File
|
1999-11-13
|
6KB
|
221 lines
/* Optimized with RexxOpt 1.7 */
NL='0A'X
TempFile="ram:HTMLfound"
say "***************************************************"
say "*
External Link Checker
V1.4 (09/09/97) *"
say "* © Heiko Schröder (age@thepentagon.com) *"
say "***************************************************"||NL
if ~show('L',"rexxreqtools.library") then;do
if ~addlib('rexxreqtools.library',0,-30,0) then;do
say "You need LIBS:rexxreqtools.library. Cancel"
Call Fini
END
END
SIGNAL ON BREAK_C
call rtezrequest("Which browser do you prefer?","AWeb|IBrowse|Cancel","» Select browser «",,fonttag "rtez_defaultresponse = 1",result)
if result=1 then Browser="AWEB"
if result=2 then Browser="IBROWSE"
if result=0 then;do
say "Cancel"
exit
end
If Browser="AWEB" then;do
Ports=Show('P')
Parse Var Ports dummy 'AWEB.' portnr .
If portnr='' then;do
say "I cant check external links if AWEB isn't running!"
say "Please start AWEB."
Call Fini
end
end
If Browser="IBROWSE" then;do
Ports=Show('P')
a=pos("IBROWSE",upper(Ports))
If a=0 then;do
say "I cant check external links if IBrowse isn't running!"
say "Please start IBrowse."
Call Fini
end
end
verz=GetClip("xdir")
call rtezrequest("Where can i check for links?","directory|file","» LinkChecker 1.4 «",,fonttag "rtez_defaultresponse = 1",result)
if result=1 then;do
dir=rtfilerequest(verz,,"Pick a directory and OK",,"rtfi_flags = freqf_nofiles")
if rtresult=0 then;do
echo "Cancel"
Exit
End
pat="PAT=#?.#?(htm|html)"
say "Checking: "||dir
void=SetClip("xdir",dir)
directory=dir
if dir~="" then dir=d2c(34)||dir||d2c(34)
address command "list >"TempFile dir pat||" quick nohead files all lformat %s%s"
end
else;do
file=rtfilerequest(verz,,"Pick a file and OK",,)
if rtresult=0 then;do
echo "Cancel"
Exit
End
Open("HTML",TempFile,"W")
writeln("HTML",file)
Close("HTML")
pos=max(pos(":",file),lastpos("/",file))
dir=Left(file,pos)
say "Checking: "||dir
void=SetClip("xdir",dir)
end
Time('R')
Datei=0;Fehler=0;Links=0
Open("LCR","T:LinkCheckResult","W")
Open("HTML",TempFile,"R")
DO WHILE 1
htmlfile=ReadLn('HTML')
IF EOF('HTML') THEN leave
Datei=Datei+1
ende=0
zeile=0
say d2c(11)||copies(" ",70)||d2c(11)
say "Checking: "DelStr(htmlfile,1,length(directory))
say "Files: "||Datei||" - Links: "||links||" - Errors:
"||Fehler||"
"d2c(11)
Open("CHECK",htmlfile,"R")
DO WHILE ende=0
Do WHILE ende=0
line=Readln('CHECK')
IF EOF('CHECK') THEN ende=1
zeile=zeile+1
if length(line)>7 then leave
End
DO WHILE 1
pos1=max(lastpos('SRC=',upper(line)),lastpos('HREF=',upper(line)))
IF pos1=0 then leave
pos13=min(pos('=',line,pos1),pos('="',line,pos1))
Select
When pos13=0 then pos1=pos('=',line,pos1)
When pos13<pos1+7 then pos1=pos13
Otherwise NOP
End
link=Delstr(line,1,pos1)
pos21=pos(d2c(34),link,2);if pos21=0 then pos21=99999
pos22=pos(" ",link,2);if pos22=0 then pos22=99999
pos23=pos("#",link,2);if pos23=0 then pos23=99999
pos24=pos(">",link,2);if pos24=0 then pos24=99999
pos2=min(pos21,pos22,pos23,pos24)
IF pos2=99999 then leave
line=Left(line,pos1-2)
link=DelStr(link,pos2)
link=strip(link,B,d2c(34))
link=strip(link,B,"=")
if pos(""",link)=0 then;do
retrieve=1
outlink=0
if pos("HTTP://",upper(link)) ~=0 then outlink=1
if pos("FTP://",upper(link)) ~=0 then outlink=1
if pos("GOPHER://",upper(link)) ~=0 then outlink=1
if pos("TELNET://",upper(link)) ~=0 then outlink=1
if pos("ABOUT:",upper(link)) ~=0 then outlink=1
if pos("FILE://",upper(link)) ~=0 then outlink=1
if outlink=1 then;do
If Browser="AWEB" then;do
address value 'AWEB.'||portnr
Open link
Wait Doc
SaveAs "T:LinkChecker.tmp"
address 'REXX'
Open("TMP","T:LinkChecker.tmp","R")
extline=readln('TMP')
Close("TMP")
IF pos("<HTML><H1>ERROR</H1>",upper(extline))~=0 then retrieve=0
end
If Browser="IBROWSE" then;do
address value 'IBROWSE'
GotoUrl link
a=result
if a~=0 then retrieve=0
end
end
else;do
leave
end
links=links+1
if retrieve=0 then;do
Fehler=Fehler+1
writeln("LCR",htmlfile||" -> "||link||" -> line: "||zeile)
end
say "Files: "||Datei||" - Links: "||links||" - Errors:
"||Fehler||"
"d2c(11)
end
END
END
Close("CHECK")
END
Close("HTML")
Close("LCR")
Zeit=TIME('E')
address command "delete ram:HTMLfound QUIET"
address command "delete T:LinkChecker.tmp QUIET"
say "Files: "||Datei||" - Links: "||links||" - Errors:
"||Fehler||"
"
If Fehler~=0 then
say "Sorry. There were link errors. They are listed in T:LinkCheckResult."
else
say "Great. No external link errors :-)"
SAY "Elapsed time: "Zeit" sec."
Open("LCR","T:LinkCheckResult","R")
z=0
File.0=Fehler
Link.0=Fehler
Line.0=Fehler
DO WHILE 1
line=ReadLn('LCR')
IF (EOF('LCR')|line='') THEN leave
z=z+1
pos1=pos(" -> ",line)
pos2=pos(" -> ",line,pos1+1)
File.z=Left(line,pos1)
Link.z=Delstr(line,1,pos1+3);Link.z=Left(Link.z,pos2-pos1-4)
Line.z=Delstr(line,1,pos2+9)
End
Close("LCR")
if z=0 then Call Fini
quit=0;del=0;t=1
Do While quit=0
call rtezrequest("Error: "t"/"Fehler||NL||" File: "File.t||NL||" Link: "Link.t||NL||" Line: "Line.t,"Prev|Next|I know|Leave","» Link Errors «",,fonttag "rtez_defaultresponse = 1",result)
if (result=1&t~=1) then t=t-1
if (result=2&t~=z) then t=t+1
if result=3 then del=1
if result=0 then quit=1
if del=1 then;do
if z~=t then;do
do r=t to z-1
e=r+1
File.r=File.e
Link.r=Link.e
Line.r=Line.e
end
end
else;do
r=t-1
t=t-1
end
File.0=r;if r=0 then quit=1
Link.0=r
Line.0=r
z=z-1
Fehler=Fehler-1
del=0
end
End
exit
Fini:
PARSE PULL Keyword
exit
BREAK_C:
say Copies(" ",75)
say "You have canceled."
Close("CHECK")
Close("HTML")
Close("LCR")
address command "delete ram:HTMLfound QUIET"
Parse Pull Keyword
Exit